Hi!
I've already asked this question in this forum with the heading "Data Execution Prevention".
Please refer the following link:
How do I check whether I've corrupted the buffer?
I've deleted all the variable I've used.
Please tell me how to get around this error?
Here is my code:
#include "irrlicht.h"
#include "CEGUI.h"
#include "CEGUIIrrlichtRenderer.h"
#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L)
using namespace std;
using namespace CEGUI;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
IrrlichtDevice* device = createDevice(EDT_DIRECT3D9, core::dimension2d<u32>(800, 600), 16, false);
CEGUI::IrrlichtRenderer &myRenderer = CEGUI::IrrlichtRenderer::bootstrapSystem(*device);
class InitialMenu : public IEventReceiver
{
private:
WindowManager* wmgr;
Window* myRoot, *playWnd, *optionsWnd, *creditsWnd, *initialMnuBG_img, *playMnuBG_img, *optionsMnuBG_img, *creditsMnuBG_img;
FrameWindow* fWnd;
DefaultResourceProvider* rp;
CEGUI::PushButton* play_btn, *options_btn, *credits_btn, *exit_btn;
CEGUI::Image* playercty_img, *oppcty_img;
CEGUI::Combobox* playercty_cbo, *oppcty_cbo;
CEGUI::PushButton* playMnuBack_btn, *playMnuNext_btn, *optionsMnuBack_btn, *optionsMnuNext_btn;
CEGUI::PushButton* creditsMnuBack_btn;
CEGUI::Scrollbar* music_scr, *sound_scr;
public:
InitialMenu()
{
rp = static_cast<DefaultResourceProvider*>(System::getSingleton().getResourceProvider());
rp->setResourceGroupDirectory ("schemes", "datafiles/schemes/");
rp->setResourceGroupDirectory ("imagesets", "datafiles/imagesets/");
rp->setResourceGroupDirectory ("fonts", "datafiles/fonts/");
rp->setResourceGroupDirectory ("layouts", "datafiles/layouts/");
rp->setResourceGroupDirectory ("looknfeel", "datafiles/looknfeel/");
rp->setResourceGroupDirectory ("lua_scripts", "../datafiles/lua_scripts/");
CEGUI::Imageset::setDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeel");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme","schemes");
FontManager::getSingleton().createFreeTypeFont("DejaVuSans-10.font",10,false, "DejaVuSans.ttf");
WidgetLookManager::getSingleton().parseLookNFeelSpecification("TaharezLook.looknfeel", "looknfeel");
wmgr = WindowManager::getSingletonPtr();
wmgr->loadWindowLayout("E://CricCEGUI//datafiles//layouts//VanillaWindows.layout", "", "", 0, 0);
myRoot = wmgr->createWindow("DefaultWindow", "root");
System::getSingleton().setGUISheet(myRoot);
fWnd = (FrameWindow*)wmgr->createWindow("TaharezLook/FrameWindow", "");
fWnd->setPosition(UVector2(UDim(0.25f, 0.0f), UDim(0.25f, 0.0f)));
fWnd->setSize(UVector2(UDim(0.5f, 0.5f), UDim(0.5f, 0.5f)));
fWnd->setText("Hello World!");
myRoot->addChildWindow(fWnd);
fWnd->setSizingEnabled(true);
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
play_btn = (PushButton*) wmgr->createWindow("TaharezLook/Button", "play_btn");
options_btn = (PushButton*) wmgr->createWindow("TaharezLook/Button", "options_btn");
credits_btn = (PushButton*) wmgr->createWindow("TaharezLook/Button", "credits_btn");
exit_btn = (PushButton*) wmgr->createWindow("TaharezLook/Button", "exit_btn");
ImagesetManager::getSingleton().createFromImageFile("initialMnuBG_img", "E:\\CricCEGUI\\bg.png", " ");
initialMnuBG_img = wmgr->createWindow("TaharezLook/StaticImage", "initialMnuBG_img");
initialMnuBG_img->setArea(URect (cegui_reldim (0), cegui_reldim (0), cegui_reldim (1), cegui_reldim (1)));
initialMnuBG_img->setProperty("FrameEnabled", "false");
initialMnuBG_img->setProperty("BackgroundEnabled", "false");
initialMnuBG_img->setProperty("Image", "set:initialMnuBG_img image:full_image");
fWnd->addChildWindow(initialMnuBG_img);
fWnd->addChildWindow(play_btn);
fWnd->addChildWindow(options_btn);
fWnd->addChildWindow(credits_btn);
fWnd->addChildWindow(exit_btn);
play_btn->setPosition(UVector2(UDim(0.22f, 11.5f), UDim(0.05f, 11.5f)));
play_btn->setSize(UVector2(UDim(0.2f, 0.15f), UDim(0.15f, 0.15f)));
play_btn->setText("Play");
play_btn->setProperty("NormalImage", "E:/CricCEGUI/bg.png");
options_btn->setPosition(UVector2(UDim(0.25f, 0.25f), UDim(0.25f, 0.25f)));
options_btn->setSize(UVector2(UDim(0.2f, 0.15f), UDim(0.15f, 0.15f)));
options_btn->setText("Options");
credits_btn->setPosition(UVector2(UDim(0.18f, 28.6f), UDim(0.3f, 28.6f)));
credits_btn->setText("Credits");
credits_btn->setSize(UVector2(UDim(0.2f, 0.15f), UDim(0.15f, 0.15f)));
exit_btn->setPosition(UVector2(UDim(0.07f, 71.2f), UDim(0.3f, 71.2f)));
exit_btn->setSize(UVector2(UDim(0.2f, 0.15f), UDim(0.15f, 0.15f)));
exit_btn->setText("Exit");
System::getSingleton().setDefaultFont("DejaVuSans-10.font");
System::getSingleton().setDefaultTooltip("TaharezLook/Tooltip");
CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton);
CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton);
play_btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&InitialMenu::playHandler, this));
options_btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&InitialMenu::optionsHandler, this));
credits_btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&InitialMenu::creditsHandler, this));
exit_btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&InitialMenu::exitHandler, this));
}
bool playHandler(const EventArgs& e)
{
wmgr = WindowManager::getSingletonPtr();
playWnd = (FrameWindow*)wmgr->createWindow("TaharezLook/FrameWindow", "playWnd");
playWnd->setPosition(UVector2(UDim(0.25f, 0.0f), UDim(0.25f, 0.0f)));
playWnd->setSize(UVector2(UDim(0.5f, 0.5f), UDim(0.5f, 0.5f)));
System::getSingleton().setGUISheet(playWnd);
playercty_img = (Image*) wmgr->createWindow("TaharezLook/StaticImage", "playercty_img");
oppcty_img = (Image*) wmgr->createWindow("TaharezLook/StaticImage", "oppcty_img");
playercty_cbo = (Combobox*) wmgr->createWindow("TaharezLook/Combobox", "playercty_cbo");
oppcty_cbo = (Combobox*) wmgr->createWindow("TaharezLook/Combobox", "oppcty_cbo");
playMnuBack_btn = (PushButton*) wmgr->createWindow("TaharezLook/Button", "playMnuBack_btn");
playMnuNext_btn = (PushButton*) wmgr->createWindow("TaharezLook/Button", "playMnuNext_btn");
ImagesetManager::getSingleton().createFromImageFile("playMnuBG_img", "E:\\CricCEGUI\\Forest.png", "");
playMnuBG_img = wmgr->createWindow("TaharezLook/StaticImage", "playMnuBG_img");
playMnuBG_img->setArea(URect (cegui_reldim (0), cegui_reldim (0), cegui_reldim (1), cegui_reldim (1)));
playMnuBG_img->setProperty("FrameEnabled", "false");
playMnuBG_img->setProperty("BackgroundEnabled", "false");
playMnuBG_img->setProperty("Image", "set:playMnuBG_img image:full_image");
playWnd->addChildWindow(playMnuBG_img);
playWnd->addChildWindow(playercty_img->getName());
playWnd->addChildWindow(oppcty_img->getName());
playWnd->addChildWindow(playercty_cbo);
playWnd->addChildWindow(oppcty_cbo);
playWnd->addChildWindow(playMnuBack_btn);
playWnd->addChildWindow(playMnuNext_btn);
return true;
}
bool optionsHandler(const EventArgs& e)
{
wmgr = WindowManager::getSingletonPtr();
optionsWnd = (FrameWindow*)wmgr->createWindow("TaharezLook/FrameWindow", "optionsWnd");
optionsWnd->setPosition(UVector2(UDim(0.25f, 0.0f), UDim(0.25f, 0.0f)));
optionsWnd->setSize(UVector2(UDim(0.5f, 0.5f), UDim(0.5f, 0.5f)));
System::getSingleton().setGUISheet(optionsWnd);
music_scr = (Scrollbar*)wmgr->createWindow("TaharezLook/Scrollbar", "music_scr");
sound_scr = (Scrollbar*)wmgr->createWindow("TaharezLook/Scrollbar", "sound_scr");
optionsMnuBack_btn = (PushButton*)wmgr->createWindow("TaharezLook/Button", "optionsMnuBack_btn");
optionsMnuNext_btn = (PushButton*)wmgr->createWindow("TaharezLook/Button", "optionsMnuNext_btn");
optionsMnuBack_btn->setPosition(UVector2(UDim(0.02f, 71.2f), UDim(0.3f, 71.2f)));
optionsMnuBack_btn->setSize(UVector2(UDim(0.2f, 0.15f), UDim(0.15f, 0.15f)));
optionsMnuBack_btn->setPosition(UVector2(UDim(1.5f, 71.2f), UDim(1.5f, 71.2f)));
optionsMnuNext_btn->setSize(UVector2(UDim(0.2f, 0.15f), UDim(0.15f, 0.15f)));
ImagesetManager::getSingleton().createFromImageFile("optionsMnuBG_img", "E:\\CricCEGUI\\bg.png", "");
optionsMnuBG_img = wmgr->createWindow("TaharezLook/StaticImage", "optionsMnuBG_img");
optionsMnuBG_img->setArea(URect (cegui_reldim (0), cegui_reldim (0), cegui_reldim (1), cegui_reldim (1)));
optionsMnuBG_img->setProperty("FrameEnabled", "false");
optionsMnuBG_img->setProperty("BackgroundEnabled", "false");
optionsMnuBG_img->setProperty("Image", "set:optionsMnuBG_img image:full_image");
optionsWnd->addChildWindow(optionsMnuBG_img);
return true;
}
bool creditsHandler(const EventArgs& e)
{
wmgr = WindowManager::getSingletonPtr();
creditsWnd = (FrameWindow*)wmgr->createWindow("TaharezLook/FrameWindow", "creditsWnd");
creditsWnd->setPosition(UVector2(UDim(0.25f, 0.0f), UDim(0.25f, 0.0f)));
creditsWnd->setSize(UVector2(UDim(0.5f, 0.5f), UDim(0.5f, 0.5f)));
creditsMnuBack_btn = (PushButton*)wmgr->createWindow("TaharezLook/Button", "creditsMnuBack_btn");
creditsMnuBack_btn->setPosition(UVector2(UDim(1.5f, 71.2f), UDim(1.5f, 71.2f)));
creditsMnuBack_btn->setSize(UVector2(UDim(0.2f, 0.15f), UDim(0.15f, 0.15f)));
ImagesetManager::getSingleton().createFromImageFile("creditsMnuBG_img", "E:\\CricCEGUI\\bg.png", "");
creditsMnuBG_img = wmgr->createWindow("TaharezLook/StaticImage", "creditsMnuBG_img");
creditsMnuBG_img->setArea(URect (cegui_reldim (0), cegui_reldim (0), cegui_reldim (1), cegui_reldim (1)));
creditsMnuBG_img->setProperty("FrameEnabled", "false");
creditsMnuBG_img->setProperty("BackgroundEnabled", "false");
creditsMnuBG_img->setProperty("Image", "set:creditsMnuBG_img image:full_image");
creditsWnd->addChildWindow(creditsMnuBG_img);
return true;
}
bool exitHandler(const EventArgs& e)
{
WindowManager::getSingleton().destroyWindow(myRoot);
return true;
}
virtual bool OnEvent(const SEvent& event)
{
bool retval = ::myRenderer.injectEvent(event);
if(retval)
{
return true;
}
return false;
}
void Run()
{
video::IVideoDriver* driver = ::device->getVideoDriver();
ISceneManager* smgr = ::device->getSceneManager();
while (::device->run() && driver)
{
if(::device->isWindowActive())
{
driver->beginScene(true, true, SColor(150, 50, 50, 50));
smgr->drawAll();
System::getSingleton().renderGUI();
driver->endScene();
}
::device->drop();
}
}
~InitialMenu()
{
delete[] InitialMenu::play_btn;
delete[] InitialMenu::credits_btn;
delete[] InitialMenu::exit_btn;
delete[] InitialMenu::fWnd;
delete[] InitialMenu::myRoot;
delete[] InitialMenu::oppcty_cbo;
delete[] InitialMenu::oppcty_img;
delete[] InitialMenu::options_btn;
delete[] InitialMenu::playercty_cbo;
delete[] InitialMenu::playercty_img;
delete[] InitialMenu::playMnuBack_btn;
delete[] InitialMenu::playMnuNext_btn;
delete[] InitialMenu::playWnd;
delete[] InitialMenu::rp;
delete[] InitialMenu::wmgr;
delete[] InitialMenu::creditsWnd;
delete[] InitialMenu::creditsMnuBack_btn;
delete[] InitialMenu::optionsMnuBack_btn;
delete[] InitialMenu::optionsMnuNext_btn;
delete[] InitialMenu::optionsWnd;
delete[] InitialMenu::music_scr;
delete[] InitialMenu::sound_scr;
delete[] InitialMenu::initialMnuBG_img;
delete[] InitialMenu::playMnuBG_img;
delete[] InitialMenu::optionsMnuBG_img;
delete[] InitialMenu::creditsMnuBG_img;
delete device;
}
};
int main ()
{
InitialMenu* initMenu = new InitialMenu();
initMenu->Run();
initMenu->~InitialMenu();
return 0;
}
|